package com.oa.co.controller;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

import com.oa.co.common.R;
import com.oa.co.pojo.User;
import com.oa.co.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author sunXuDong
 * @data 2023/5/3
 */
@RestController
@CrossOrigin("*")
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private UserService userService;
    //登录
    @RequestMapping("/login")
    public R login(String username, String password, HttpServletRequest request){
        return userService.login(username,password,request);
    }
    //注册
    @RequestMapping("/adduser")
    public R adduser(@RequestBody User user){
        return userService.adduser(user);
    }
    //找回密码
    @RequestMapping("/retrievePassword")
    public R rPwd( String username,String phone,String password,String passwordIs){
        return userService.rPwd(username,phone,password,passwordIs);
    }
    //修改个人信息
    @RequestMapping("upInfo")
    public R upInfo(User user){
        return userService.upInfo(user);
    }
    //登录后修改密码
    @RequestMapping("interiorPassword")
    public R interiorPassword(String password,String passwordIs1,String passwordIs2,Integer id){

        return userService.interiorPassword(password,passwordIs1,passwordIs2,id);
    }

}
